#include <amxmodx>
#include <umitem>

new PLUGIN_NAME[] 	= "UM Item: Pointer"
new PLUGIN_AUTHOR[] 	= "Cheap_Suit"
new PLUGIN_VERSION[] 	= "1.0"

new bool:g_Pointer[33]
public plugin_init() 
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	register_event("DeathMsg", "Event_DeathMsg", "a")
	register_event("ResetHUD", "Event_ResetHUD", "be")
	register_item("'+' Pointer", "Extra crosshair", 900)
}

public client_connect(id) {
	g_Pointer[id] = false
}

public Event_ResetHUD(id)
{
	if(!is_user_connected(id) || !is_user_alive(id)) {
		return PLUGIN_CONTINUE
	}
	
	if(g_Pointer[id]) 
	{
		if(!task_exists(id)) {
			set_task(1.0, "pointer_loop", id, _, _, "b")
		}
	}
	return PLUGIN_CONTINUE
}

public Enable_Item(id) 
{
	g_Pointer[id] = true
	set_task(1.0, "pointer_loop", id, _, _, "b")
}

public Disable_Item(id) 
{
	g_Pointer[id] = false
	if(task_exists(id)) {
		remove_task(id)
	}
}

public Event_DeathMsg() 
{
	if(task_exists(read_data(2))) {
		remove_task(read_data(2))
	}
}

public pointer_loop(id)
{
	if(!is_user_connected(id) || !is_user_alive(id) || !g_Pointer[id]) 
	{
		if(task_exists(id)) {
			remove_task(id)
		}
		return PLUGIN_CONTINUE
	}
	
	set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 0.0, 1.1, 0.0, 0.0, 10)
	show_hudmessage(id, "+")
	
	return PLUGIN_CONTINUE
}
